home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Visual Basic Source Code
/
Visual Basic Source Code.iso
/
vbsource
/
c_arr1a
/
frmc_arr.frm
< prev
next >
Wrap
Text File
|
1999-09-19
|
4KB
|
153 lines
VERSION 5.00
Begin VB.Form Form1
Caption = "cArray Example"
ClientHeight = 3195
ClientLeft = 60
ClientTop = 345
ClientWidth = 4680
LinkTopic = "Form1"
ScaleHeight = 3195
ScaleWidth = 4680
StartUpPosition = 3 'Windows Default
Begin VB.CommandButton cmdSet
Caption = "Set"
Height = 495
Left = 3360
TabIndex = 6
Top = 2280
Width = 1215
End
Begin VB.CommandButton cmdGet
Caption = "Get"
Height = 495
Left = 3360
TabIndex = 5
Top = 1680
Width = 1215
End
Begin VB.CommandButton cmdDown
Caption = "Down"
Height = 495
Left = 3240
TabIndex = 4
Top = 840
Width = 975
End
Begin VB.CommandButton cmdUp
Caption = "Up"
Height = 495
Left = 3240
TabIndex = 3
Top = 240
Width = 975
End
Begin VB.CommandButton cmdRemove
Caption = "Remove"
Height = 375
Left = 1680
TabIndex = 2
Top = 2280
Width = 1215
End
Begin VB.CommandButton cmdAdd
Caption = "Add"
Height = 375
Left = 120
TabIndex = 1
Top = 2280
Width = 1335
End
Begin VB.ListBox lstArray
Height = 1815
Left = 120
TabIndex = 0
Top = 120
Width = 3015
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'I didn't go to alot of trouble with this form, because
'I knew that you guys will be smart enough to figure
'out how the class work. Good luck.
Dim myA As c_Array
Private Sub cmdAdd_Click()
itemValue = InputBox("Enter Text")
Key = InputBox("Enter Key")
myA.Add itemValue, Key
Update
End Sub
Private Sub cmdRemove_Click()
If MsgBox("Yes: Enter Key No: Enter Index", vbYesNo) = vbYes Then
Key = InputBox("Enter key:", "Remove")
myA.Remove , Key
Else
Index = InputBox("Enter Index:", "Remove")
myA.Remove Index
End If
Update
End Sub
Private Sub cmdUp_Click()
If lstArray.ListIndex = -1 Then
Beep
Exit Sub
End If
myA.MoveUp lstArray.ListIndex + 1
Update
End Sub
Private Sub cmdDown_Click()
If lstArray.ListIndex = -1 Then
Beep
Exit Sub
End If
myA.MoveDown lstArray.ListIndex + 1
Update
End Sub
Private Sub cmdGet_Click()
If MsgBox("Yes: Enter Key No: Enter Index", vbYesNo) = vbYes Then
Key = InputBox("Enter Key:")
MsgBox myA.Itemget(, Key)
Else
Index = InputBox("Enter Index:")
MsgBox myA.Itemget(Index)
End If
End Sub
Private Sub cmdSet_Click()
If MsgBox("Yes: Enter Key No: Enter Index", vbYesNo, "Set") = vbYes Then
Key = InputBox("Enter Key:", "Set")
newVal = InputBox("Enter new value:", "Set")
myA.Itemset newVal, , Key
Else
Index = InputBox("Enter Index", "Set")
newVal = InputBox("Enter new value:", "Set")
myA.Itemset newVal, Index
End If
Update
End Sub
Private Sub Form_Load()
Set myA = New c_Array
End Sub
Function Update()
lstArray.Clear
For i = 1 To myA.Count
lstArray.AddItem myA.Itemget(i)
Next
End Function